package org.jeecg.modules.demo.com.kunpeng.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.demo.com.kunpeng.entity.dto.OaOtherContractUpdateDTO;
import org.jeecg.modules.demo.com.kunpeng.entity.dto.OaPurchaseContractUpdateDTO;
import org.jeecg.modules.demo.com.kunpeng.entity.dto.OaSaleContractUpdateDTO;
import org.jeecg.modules.demo.com.kunpeng.service.IOaContractService;
import org.jeecg.modules.demo.com.kunpeng.vo.OaOtherContractPage;
import org.jeecg.modules.demo.com.kunpeng.vo.OaPurchaseContractPage;
import org.jeecg.modules.demo.com.kunpeng.vo.OaSaleContractPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags="OA合同表")
@RestController
@RequestMapping("/com.kunpeng/OaContract")
@Slf4j
public class OaContractController {

    @Autowired
    private IOaContractService oaContractService;

    /**
     * 添加
     * @param oaSaleContractPage
     * @return
     */
    @AutoLog(value = "OA销售合同表-添加")
    @ApiOperation(value="OA销售合同表-添加", notes="OA销售合同表-添加")
    //@RequiresPermissions("com.kunpeng:sale_contract:add")
    @PostMapping(value = "/addOaSaleContract")
    public Result<String> addOaSaleContract(@RequestBody OaSaleContractPage oaSaleContractPage) {
        System.out.println("oaSaleContractPage:"+oaSaleContractPage.toString());
        oaContractService.insertOaSaleContract(oaSaleContractPage);
        /*saleContractPage.getSaleContractCollectionPlanList()*/
        return Result.OK("销售合同添加成功！");
    }

    /**
     * 添加
     * @param oaPurchaseContractPage
     * @return
     */
    @AutoLog(value = "OA采购合同表-添加")
    @ApiOperation(value="OA采购合同表-添加", notes="OA采购合同表-添加")
    //@RequiresPermissions("com.kunpeng:sale_contract:add")
    @PostMapping(value = "/addOaPurchaseContract")
    public Result<String> addOaPurchaseContract(@RequestBody OaPurchaseContractPage oaPurchaseContractPage) {
        System.out.println("oaPurchaseContractPage:"+oaPurchaseContractPage.toString());
        oaContractService.insertOaPurchaseContract(oaPurchaseContractPage);
        /*saleContractPage.getSaleContractCollectionPlanList()*/
        return Result.OK("采购合同添加成功！");
    }

    /**
     * 添加
     * @param oaOtherContractPage
     * @return
     */
    @AutoLog(value = "OA其他合同表-添加")
    @ApiOperation(value="OA其他合同表-添加", notes="OA其他合同表-添加")
    @PostMapping(value = "/addOaOtherContract")
    public Result<String> addOaOtherContract(@RequestBody OaOtherContractPage oaOtherContractPage) {
        System.out.println("oaOtherContractPage:"+oaOtherContractPage.toString());
        oaContractService.insertOaOtherContract(oaOtherContractPage);
        /*saleContractPage.getSaleContractCollectionPlanList()*/
        return Result.OK("其他合同添加成功！");
    }

    /**
     * 编辑销售合同数据
     * @param oaSaleContractUpdateDTO
     * @return
     */
    @AutoLog(value = "OA销售合同表-编辑")
    @ApiOperation(value="OA销售合同表-编辑", notes="OA销售合同表-编辑")
    @PostMapping(value = "/updateOaSaleContract")
    public Result<String> updateOaSaleContract(@RequestBody OaSaleContractUpdateDTO oaSaleContractUpdateDTO) {
        oaContractService.updateOaSaleContract(oaSaleContractUpdateDTO);
        return Result.OK("销售合同编辑成功！");
    }

    /**
     * 编辑采购合同数据
     * @param oaPurchaseContractUpdateDTO
     * @return
     */
    @AutoLog(value = "OA采购合同表-编辑")
    @ApiOperation(value="OA采购合同表-编辑", notes="OA采购合同表-编辑")
    @PostMapping(value = "/updateOaPurchaseContract")
    public Result<String> updateOaPurchaseContract(@RequestBody OaPurchaseContractUpdateDTO oaPurchaseContractUpdateDTO) {
        oaContractService.updateOaPurchaseContract(oaPurchaseContractUpdateDTO);
        return Result.OK("采购合同编辑成功！");
    }

    /**
     * 编辑其他合同数据
     * @param oaOtherContractUpdateDTO
     * @return
     */
    @AutoLog(value = "OA其他合同表-编辑")
    @ApiOperation(value="OA其他合同表-编辑", notes="OA其他合同表-编辑")
    @PostMapping(value = "/updateOaOtherContract")
    public Result<String> updateOaOtherContract(@RequestBody OaOtherContractUpdateDTO oaOtherContractUpdateDTO) {
        oaContractService.updateOaOtherContract(oaOtherContractUpdateDTO);
        return Result.OK("其他合同编辑成功！");
    }

}
